#include "function.h"
#include "struct.h"

/**
 * @brief 按isbn查找
 * 
 * @param list 
 * @param book 
 */
void find_isbn(p_node list, Book book)
{
    printf("请输入您要查找的书籍的isbn:");
    char arr[20] = {0};
    scanf("%19s", arr);                     //限制输入长度，防止溢出
    p_node current = list;
    while(current != NULL)
    {
        if(strcmp(arr, current->data.isbn) == 0 )
        {
            //显示这本书的信息
            printf("书名:%s\n作者:%s\nISBN:%s\n出版社:%s\n年份:%d\n库存:%d\n已借出数量:%d\n", \
            current->data.title, current->data.author, current->data.isbn, current->data.publisher, \
            current->data.year, current->data.stock, current->data.borrowed); 
            return;      //找到一本后结束,因为ISBN是唯一的
        }
        current = current->next;
    }
    // 没有要找的书的情况
    printf("该系统中没有您要查找的isbn书籍\n");
}